#include <iostream>
#include <string>
using namespace std;

int main()
{
    // 方式1
    int *p = new int(10);

    // 方式2
    int *q = new int;
    *q = 11;

    // 方式3
    int *z = nullptr;
    z = new int(12);

    cout << p << ", " << q << ", " << z << endl;
    cout << *p << ", " << *q << ", " << *z << endl;

    int *pp = new int[5];
    pp[0] = 21;
    pp[4] = 25;
    cout << pp[0] << ", " << pp[4] << endl;

    // 释放内存
    delete p;
    delete q;
    delete z;

    // 必要时
    z = nullptr;

    // 释放连续内存（数组）
    delete[] pp;

    return 0;
}